<?php
/**
 * SystemClassLoader is the default ClassLoader that loads class files from
 * the referenced class paths.
 *
 * @package be.appcraft.util
 * @version $Revision: 1.3 $
 *
 * @author Stijn Van Bael
 * @since 1.0
 */
class Pageley_Util_SystemClassLoader implements Pageley_Util_ClassLoader {

	public function loadClass($className) {
       $this->loadResource($className, $_REQUEST["system.classLocation"]);
	}
    
	public function loadConfig($configName) {
       $this->loadResource($configName, $_REQUEST["system.resourceLocation"]);
	}

    private function loadResource($resourceName, $location) {
		$system = Pageley_Util_System::getInstance();
        $resourceFile = $location . Pageley_Util_String::replace($resourceName, "_", "/") . ".php";
		try {
		    include($resourceFile);
		} catch(Exception $e) {
			throw new Pageley_Util_NoSuchClassException("Resource '" . $resourceFile . "' does not exist.", E_WARNING, $e);
		}
    }
}